package com.hjj.concurrence.singleton;

/**
 * 在方法中加synchronized，会导致这个方法比较低效，导致性能下降
 *
 * @author hjj
 * @create 2019-12-16 10:20
 */
public class Singleton2 {
    private static Singleton2 singleton2;

    private Singleton2() {
    }

    public static synchronized Singleton2 getInstance() {
        if (singleton2 == null) {
            singleton2 = new Singleton2();
        }
        return singleton2;
    }
}
